package FirstSecond;

public class PriorDemo {
	public static int MIN_PRIORITY = 1;
	public static int NORN_PRIORITY = 5;
	public static int MAX_PRIORITY = 10;
	
	public static class HighestPriority extends Thread {
		static int count = 0;
		
		@Override
		public void run() {
			while(true) {
				synchronized(PriorDemo.class) {
					count++;
					if(count>100000000) {
						System.out.println("HighPriority is complete");
						break;
					}
				}
			}
		}
	}
	
	public static class LowPriority extends Thread {
		static int count = 0;
		
		@Override
		public void run() {
			while(true) {
				synchronized(PriorDemo.class) {
					count++;
					if(count>100000000) {
						System.out.println("LowPriority is complete");
						break;
					}
				}
			}
		}
	}
	
	public static void main(String[] args) throws InterruptedException {
		Thread high = new HighestPriority();
		LowPriority low = new LowPriority();
		
		high.setPriority(MAX_PRIORITY);
		low.setPriority(MIN_PRIORITY);
	
		low.start();
		high.start();
	}
}
